const express = require('express');
const app = express();

const port = 3000;

// 先配置CORS中间件
app.use(function (req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('Access-Control-Allow-Methods', '*');
    res.setHeader('Access-Control-Allow-Headers', '*');
    if (req.method === 'OPTIONS') {
        res.sendStatus(200);
        return;
    }
    next();
});

// 再配置解析中间件
app.use(express.urlencoded({extended:false}));

// 最后加载路由
const recReadingRoute = require('./Harmony_SmartFun/routers/rcmKonwledgeRoute');
const streamRouter = require('./Harmony_SmartFun/dao/ds_StreamRequire');
app.use('/api', recReadingRoute);

app.use('/api', streamRouter);



app.listen(80, (req, res) => {
    console.log('Server started on port 80');
});